package com.xzzz.backend.blog.config.constants;

import org.springframework.cache.annotation.CacheConfig;

import java.util.concurrent.TimeUnit;

/**
 * 系统参数
 * @author xzzz
 */
public interface XzConstants {
    /* ======================================== http 请求头 ======================================== */
    String HTTP_HEADER_AUTHORIZATION = "Authorization";
    Integer DEFAULT_USER_ID = 1;

    Integer DEFAULT_FOLDER_ID = -1;
    String  DEFAULT_OS_PATH   = "default/";

    String DEV_DB_NAME  = "DEV";
    String DEV_INFO     = "[开发库], 可放心操作.";
    String PROD_WARNING = "[生产库], 请小心操作!!!";


    /**───────────────────────────────────────────────────────────────────────────────────────────────────**
     *                                                Redis
     **───────────────────────────────────────────────────────────────────────────────────────────────────**/
    interface Redis {
        // ------------------------- cache 前后缀 -----------------------
        String CACHE_PREFIX_WITH = "xz_";
        String CACHE_SUFFIX_WITH = ":";

        // ------------------------- Redis key -------------------------
        String FOLDER = "folder";
        String WEB_COLLECT = "web_collect";

        String WEATHER_ALL = "weather_all";
        String WEATHER_NOW = "weather_now";
        String WEATHER_FORECAST = "weather_forecast";
        String WEATHER_HOURLY = "weather_hourly";


        // ------------------------- 时间单位 -------------------------
        TimeUnit REDIS_DAYS    = TimeUnit.DAYS;
        TimeUnit REDIS_HOURS   = TimeUnit.HOURS;
        TimeUnit REDIS_MINUTES = TimeUnit.MINUTES;
        TimeUnit REDIS_SECONDS = TimeUnit.SECONDS;

        // ------------------------- 时间常量 -------------------------
        int TIME_2_MINUTES  = 60 * 2;             // 2分钟  by TimeUnit.SECONDS;
        int TIME_5_MINUTES  = 60 * 5;             // 5分钟  by TimeUnit.SECONDS;
        int TIME_10_MINUTES = 60 * 10;            // 10分钟 by TimeUnit.SECONDS;
        int TIME_15_MINUTES = 60 * 15;            // 15分钟 by TimeUnit.SECONDS;

        int TIME_1_HOURS    = 60 * 60;            // 1 小时 by TimeUnit.SECONDS;
        int TIME_2_HOURS    = 60 * 60 * 2;        // 2 小时 by TimeUnit.SECONDS;
        int TIME_4_HOURS    = 60 * 60 * 4;        // 4 小时 by TimeUnit.SECONDS;
        int TIME_8_HOURS    = 60 * 60 * 8;        // 8 小时 by TimeUnit.SECONDS;

        int TIME_1_DAY      = 60 * 60 * 24;       // 1 天　 by TimeUnit.SECONDS;
        int TIME_2_DAY      = 60 * 60 * 24 * 2;   // 2 天　 by TimeUnit.SECONDS;
        int TIME_7_DAY      = 60 * 60 * 24 * 7;   // 7 天　 by TimeUnit.SECONDS;
        int TIME_30_DAY     = 60 * 60 * 24 * 30;  // 30天　 by TimeUnit.SECONDS;


        /**
         * 使用SpringCache注解的缓存名
         * <p>默认会在缓存cacheNames后增加 "::" 后缀
         * <p>在{@link CacheConfig#cacheManager}中进行了覆盖,cacheNames后使用 ":" 后缀
         * <p>若使用其他redis连接工具获取数据,则需要
         * <p>     在cacheNames前增加 "xz_" 前缀
         * <p>     在cacheNames后增加 ":" 后缀
         */
        String USER_DETAIL = "user_details";       // 用户详情
        String DICT_USERID = "xz_dict_userid:"; // 字典缓存
        String PARAM_ID    = "xz_param_id:";    // 参数缓存
        String IP_COLLECT  = "xz_ip_collect:";  // 参数缓存

        String ART_INFO    = "xz_article_info_id:";
    }

    interface Token {
        String TOKEN_PREFIX = "bearer ";
        String ACCESS_TOKEN  = "xz_access_token:";
        String REFRESH_TOKEN = "xz_refresh_token:";
    }

}
